<?php
declare(strict_types=1);

namespace App\Libs;
use Overtrue\EasySms\EasySms as OEasySms;

class EasySms {
	public $app;
	public function __construct() {
		$this->app = new OEasySms(config('easy_sms'));
	}
	public function send($mobile, $code){
		$ret = $this->app->send($mobile, [
		    'template' => 'SMS_190900168',
		    'data' => [
		        'code' => $code
		    ],
		]);
		return $ret;
	}

	public function check($mobile, $code){
		$cache_code = Cache::get($mobile);var_dump($cache_code);
		if(!$cache_code) return false;

		if($cache_code == $code) {
			Cache::delete($mobile);
			return true;
		}else{
			return false;
		}
	}
}